<?php
class Agency extends AppModel {
	var $name = 'Agency';
	var $primaryKey = 'id';
	
	var $validate = array(
		'name' => 'notEmpty',
		'fullname' => 'notEmpty',
		'web' => 'url'
	);
	
	var $hasMany = array(
		'Call' => array(
			'className' => 'Call',
			'foreignKey' => 'agency_id'
		)
	);
	
	//zistuje, ci je agentura pripojena k nejakej vyzve
	public function isAssociated($id) {
		return (bool) $this->Call->find('count', array('conditions' => array(
			'Call.agency_id' => $id
		)));
	}
}
?>